Last updated: 2019-09-17
Checks: 6 1
Knit directory: ~/Research-Local/RNAseq-Local/TCGA-Nigerian-RNAseq/
This reproducible R Markdown analysis was created with workflowr (version 1.4.0). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.
The R Markdown is untracked by Git. To know which version of the R Markdown file created these results, you’ll want to first commit it to the Git repo. If you’re still working on the analysis, you can ignore this warning. When you’re finished, you can run wflow_publish to commit the R Markdown file and build the HTML.
Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.
The command set.seed(20190113) was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.
Great job! Recording the operating system, R version, and package versions is critical for reproducibility.
Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.
Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.
Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility. The version displayed above was the version of the Git repository at the time these results were generated.
Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish or wflow_git_commit). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:
Ignored files:
Ignored: .DS_Store
Ignored: .Rproj.user/
Ignored: analysis/.DS_Store
Ignored: analysis/.Rhistory
Ignored: code/.DS_Store
Ignored: docs/.DS_Store
Ignored: docs/figure/.DS_Store
Ignored: docs/figure/NigerianTCGArawcountsDeSeq2-proteincoding-IHC.Rmd/.DS_Store
Ignored: plots/.DS_Store
Untracked files:
Untracked: NigerianTCGArawcountsDeSeq2-proteincoding-PAM50.Rmd
Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.
There are no past versions. Publish this analysis with wflow_publish() to start tracking its development.
#Translation from HTSeq raw counts -> Count Matrix I have 86 TCGA patients with whole-genome sequencing data and RNAseq data as well as 92 Nigerian patients with RNA-seq data. Raw counts were initially processed using HTSeq, so HTSeq data is being formatted for use with DESeq2 and limma-voom.
FOLDER <- "/Users/parajago/Research-Local/RNAseq-Local/Inputs/NigerianTCGA_quants-proteincoding"
sampleFiles <- grep("htseq.counts",list.files(FOLDER),value=TRUE)
#Differential gene expression setup based on race (b/w/other)
sampleConditionrace <- sampleFiles
countVar2=1
for (sample in sampleConditionrace){
if (stri_detect_fixed(sample,"LIB")==TRUE){
sampleConditionrace[countVar2] <- "Nigerian"
countVar2=countVar2+1
} else if (stri_detect_fixed(sample,"black")==TRUE){
sampleConditionrace[countVar2] <- "TCGA_black"
countVar2=countVar2+1
} else if (stri_detect_fixed(sample,"white")==TRUE){
sampleConditionrace[countVar2] <- "TCGA_white"
countVar2=countVar2+1
} else{
sampleConditionrace[countVar2] <- "TCGA_other"
countVar2=countVar2+1
}
}
#Condition based on PAM50 subtype
sampleConditionPAM50 <- sampleFiles
countVar2=1
for (sample in sampleConditionPAM50){
if (stri_detect_fixed(sample,"Her2")==TRUE){
sampleConditionPAM50[countVar2] <- "Her2"
countVar2=countVar2+1
} else if (stri_detect_fixed(sample,"Basal")==TRUE){
sampleConditionPAM50[countVar2] <- "Basal"
countVar2=countVar2+1
} else if (stri_detect_fixed(sample,"LumA")==TRUE){
sampleConditionPAM50[countVar2] <- "LumA"
countVar2=countVar2+1
} else if (stri_detect_fixed(sample,"LumB")==TRUE){
sampleConditionPAM50[countVar2] <- "LumB"
countVar2=countVar2+1
} else if (stri_detect_fixed(sample,"PAMNL")==TRUE){
sampleConditionPAM50[countVar2] <- "Normal"
countVar2=countVar2+1
} else{
sampleConditionPAM50[countVar2] <- "PAM_other"
countVar2=countVar2+1
}
}
#Condition based on batch (relevant to the Nigerian patients only; no difference in batch for the TCGA patients)
batchval <- sampleFiles
countVar2=1
for (sample in batchval){
if (stri_detect_fixed(sample,"batch1")==TRUE){
batchval[countVar2] <- "batch1"
countVar2=countVar2+1
} else if (stri_detect_fixed(sample,"batch23")==TRUE){
batchval[countVar2] <- "batch23"
countVar2=countVar2+1
} else if (stri_detect_fixed(sample,"batch4")==TRUE){
batchval[countVar2] <- "batch4"
countVar2=countVar2+1
} else if (stri_detect_fixed(sample,"batch5")==TRUE){
batchval[countVar2] <- "batch5"
countVar2=countVar2+1
} else{
batchval[countVar2] <- "batchT"
countVar2=countVar2+1
}
}
table(sampleConditionrace, sampleConditionPAM50)
sampleConditionPAM50
sampleConditionrace Basal Her2 LumA LumB Normal PAM_other
Nigerian 41 27 14 11 3 0
TCGA_black 23 0 4 4 0 0
TCGA_other 0 0 0 0 0 14
TCGA_white 17 5 8 9 0 0
sampleTable <- data.frame(sampleName=gsub(".htseq.counts","",sampleFiles),
fileName=sampleFiles,
condition1=sampleConditionrace,
condition2=sampleConditionPAM50,
batch=batchval)
sampleTable$sampleCondition <- paste(sampleTable$condition1, sampleTable$condition2, sep=".")
ddsHTSeqMF <- DESeqDataSetFromHTSeqCount(sampleTable=sampleTable,
directory=FOLDER,
design=~sampleCondition)
ddsHTSeqMF <- ddsHTSeqMF[rowSums(counts(ddsHTSeqMF)) > 0, ] #Pre-filtering the dataset by removing the rows without any information about gene expression -> this removes 603 genes
#Quantile normalization Please refer to: https://parajago.github.io/TCGA-Nigerian-RNAseq/NigerianTCGArawcountsDeSeq2-pc2.html regarding comparison between the Nigerian and TCGA data sets and why quantile normalization under the limma-voom approach was chosen for primary differential expression analysis.
##Data visualization
countmatrix <- assay(ddsHTSeqMF) #Raw counts organized into matrix format from individual files
countmatrix2 <- log2(countmatrix + 1) #Basic transformation of the count data
plot(density(countmatrix2[,1]),lwd=3,ylim=c(0,.30), main="Density of counts with log2[count]+1 transformation ONLY")
for(i in 1:180){lines(density(countmatrix2[,i]),lwd=3)} #This demonstrates that there is a difference in distributions between the Nigerian and TCGA data with basic log transformation normalization
norm_countmatrix <- as.matrix(countmatrix2)
norm_countmatrix = normalize.quantiles(norm_countmatrix)
plot(density(norm_countmatrix[,1]),lwd=3,ylim=c(0,.3), main="Density of counts with quantile normalization")
for(i in 1:180){lines(density(norm_countmatrix[,i]),lwd=3)} #This demonstrates the effect of comparative quantile normalization
colnames (norm_countmatrix) <- colnames (countmatrix2)
rownames (norm_countmatrix) <- rownames (countmatrix2)
norm_countmatrix <- as.data.frame(norm_countmatrix)
countmatrixNigerian <- dplyr::select(norm_countmatrix, contains("LIB"))
plot(density(countmatrixNigerian[,1]),lwd=3,ylim=c(0,.3), main="Density of counts with quantile normalization - Nigerian")
for(i in 1:96){lines(density(countmatrixNigerian[,i]),lwd=3)} #This demonstrates the result of the normalized Nigerian counts separately
tcgacolnames <- colnames(countmatrix)
tcgacolnames <- setdiff(tcgacolnames, colnames(countmatrixNigerian))
countmatrixTCGA <- norm_countmatrix[ , tcgacolnames]
plot(density(countmatrixTCGA[,1]),lwd=3,ylim=c(0,.3), main="Density of counts with quantile normalization - TCGA")
for(i in 1:84){
lines(density(countmatrixTCGA[,i]),lwd=3);
# print(colnames(countmatrix)[i])
# invisible(readline(prompt=i))
} #This demonstrates the result of the normalized TCGA counts separately
norm_countmatrix <- as.data.frame(norm_countmatrix)
t_norm_countmatrix <- t(norm_countmatrix)
t_norm_countmatrix <- cbind (t_norm_countmatrix, sampleTable) #This binds the characteristics of the original patients to the quantile normalized counts. CBinding was checked to make sure that patients were correctly aligned to characteristics.
quant.pca <- prcomp(t_norm_countmatrix[,1:19724])
autoplot(quant.pca, data=t_norm_countmatrix, colour='sampleCondition', shape='condition1', main="PCA of quantile normalization results prior to DE analysis")
In the raw data with log transformation only, we are able to see that there are two peaks corresponding to the two datasets (Nigerian and TCGA). The quantile normalization demonstrates a PCA that has similar clustering. Only ~20% of the distribution of the data set is explained by the PCA1, 2 of the variables.
##Differential expression setup
annotation <- as.data.frame(row.names(countmatrix))
colnames(annotation) <- c("GeneID")
annotation$temp <- gsub("[.].+", "", annotation[,1])
annotation$symbol <- mapIds(EnsDb.Hsapiens.v75,
keys=annotation$temp,
column="SYMBOL",
keytype="GENEID",
multiVals="first")
annotation$symbol <- mapIds(EnsDb.Hsapiens.v75,
keys=annotation$temp,
column="SYMBOL",
keytype="GENEID",
multiVals="first")
annotation$chr <- mapIds(EnsDb.Hsapiens.v75,
keys=annotation$temp,
column="SEQNAME",
keytype="GENEID",
multiVals="first")
annotation$locstart <- mapIds(EnsDb.Hsapiens.v75,
keys=annotation$temp,
column="GENESEQSTART",
keytype="GENEID",
multiVals="first")
annotation$locend <- mapIds(EnsDb.Hsapiens.v75,
keys=annotation$temp,
column="GENESEQEND",
keytype="GENEID",
multiVals="first")
annotation$temp <- NULL
design <- t_norm_countmatrix
design <- design %>% dplyr::select(sampleCondition)
Warning: The above code chunk cached its results, but it won’t be re-run if previous chunks it depends on are updated. If you need to use caching, it is highly recommended to also set knitr::opts_chunk$set(autodep = TRUE) at the top of the file (in a chunk that is not cached). Alternatively, you can customize the option dependson for each individual chunk that is cached. Using either autodep or dependson will remove this warning. See the knitr cache options for more details.
##DE: Nigerian vs. TCGA regardless of subtype
##DE: Nigerian/TCGA White - Basal
designNvsW <- design
designNvsW$sampleCondition <- ifelse (designNvsW$sampleCondition=="TCGA_white.Basal", 0, as.character(designNvsW$sampleCondition))
designNvsW$sampleCondition <- ifelse (designNvsW$sampleCondition=="Nigerian.Basal", 1, as.character(designNvsW$sampleCondition))
designNvsW$sampleCondition <- ifelse (designNvsW$sampleCondition==0 | designNvsW$sampleCondition==1, designNvsW$sampleCondition, NA)
designNvsW <- designNvsW %>% subset(is.na(sampleCondition)==FALSE)
designNvsW$TCGA_white.Basal <- ifelse (designNvsW$sampleCondition==0, 1, 0)
designNvsW$Nigerian.Basal <- ifelse (designNvsW$sampleCondition==1, 1, 0)
designNvsW$sampleCondition <- NULL
mm <- model.matrix(~0+designNvsW$TCGA_white.Basal+designNvsW$Nigerian.Basal)
quantids <- rownames(designNvsW)
rownames(mm) <- quantids
colnames(mm) <- c("TCGA_white", "Nigerian")
quantdata <- as.data.frame(t(counts(ddsHTSeqMF)))
quantdata <- quantdata[quantids,]
quantdata <- t(quantdata)
d0 <- DGEList(counts=quantdata, genes=annotation)
cutoff <- 10
drop <- which(apply(cpm(d0), 1, max) < cutoff)
d <- d0[-drop,]
dim(d) # Number of genes after taking out low expressed genes
[1] 14785 58
v=voom(d,designNvsW,plot=T, normalize="quantile")
contr.matrix <- makeContrasts(TCGA_white.Basal-Nigerian.Basal, levels=colnames(designNvsW))
fit <- lmFit(v, designNvsW)
fit <- contrasts.fit(fit, contrasts=contr.matrix)
fit <- eBayes(fit)
dt <- decideTests(fit)
summary(dt)
TCGA_white.Basal - Nigerian.Basal
Down 2346
NotSig 9093
Up 3346
hist(fit$p.value, ylim=c(0,3000), main="Histogram of unadjusted p-values of differential gene expression\n between basal breast cancers in Nigerian and TCGA white patients\n quantile corrected")
qvals<-p.adjust(fit$p.value[,1], method='fdr')
df_limma <- data_frame(log2FoldChange = fit$coefficients[,1],
pval = fit$p.value[,1],
padj = qvals,
anno = fit$genes)
with(df_limma, plot(log2FoldChange, -log10(padj), pch=20, main="Volcano plot of differential gene expression between basal \nbreast cancers in Nigerian and TCGA white breast cancer patients\nquantile corrected", xlim=c(-50,50), ylim=c(0,70)))
with(subset(df_limma, padj<0.05 & (2^(abs(log2FoldChange))>50)), points(log2FoldChange, -log10(padj), pch=20, col="blue"))
with(subset(df_limma, padj<0.05 & (2^(abs(log2FoldChange))>50)), textxy(log2FoldChange, -log10(padj), labs=anno$symbol, cex=.5))
df_limmaprint <- as.data.frame(df_limma)
df_limmaprint$foldChange <- NA
row.pos <- which(! is.na(df_limmaprint$log2FoldChange) &
df_limmaprint$log2FoldChange >= 0)
row.neg <- which(! is.na(df_limmaprint$log2FoldChange) &
df_limmaprint$log2FoldChange < 0)
df_limmaprint$foldChange[row.pos] <- 2^df_limmaprint$log2FoldChange[row.pos]
df_limmaprint$foldChange[row.neg] <- -2^((-1) * df_limmaprint$log2FoldChange[row.neg])
df_limmaprint <- df_limmaprint %>% arrange(foldChange) %>% dplyr::filter(padj < 0.05) %>% dplyr::filter(abs(foldChange)>1.5)
top_n(df_limmaprint, 10, foldChange)
top_n(df_limmaprint, -10, foldChange)
fit$genes$status <- ifelse(fit$F.p.value<0.05,"red","black")
limma::plotMA(fit, xlab = "Average log-expression",
ylab = "Expression log-ratio (this sample vs others)", status=fit$genes$status,
main = "MA Plot of differential gene expression between basal \nbreast cancers in Nigerian and TCGA white breast cancer patients")
write.csv(df_limmaprint, file = "TCGA_white-Nigerian-Basal.csv", row.names = FALSE)
Warning: The above code chunk cached its results, but it won’t be re-run if previous chunks it depends on are updated. If you need to use caching, it is highly recommended to also set knitr::opts_chunk$set(autodep = TRUE) at the top of the file (in a chunk that is not cached). Alternatively, you can customize the option dependson for each individual chunk that is cached. Using either autodep or dependson will remove this warning. See the knitr cache options for more details.
##DE: Nigerian/TCGA Black - Basal
designNvsB <- design
designNvsB$sampleCondition <- ifelse (designNvsB$sampleCondition=="TCGA_black.Basal", 0, as.character(designNvsB$sampleCondition))
designNvsB$sampleCondition <- ifelse (designNvsB$sampleCondition=="Nigerian.Basal", 1, as.character(designNvsB$sampleCondition))
designNvsB$sampleCondition <- ifelse (designNvsB$sampleCondition==0 | designNvsB$sampleCondition==1, designNvsB$sampleCondition, NA)
designNvsB <- designNvsB %>% subset(is.na(sampleCondition)==FALSE)
designNvsB$TCGA_black.Basal <- ifelse (designNvsB$sampleCondition==0, 1, 0)
designNvsB$Nigerian.Basal <- ifelse (designNvsB$sampleCondition==1, 1, 0)
designNvsB$sampleCondition <- NULL
mm <- model.matrix(~0+designNvsB$TCGA_black.Basal+designNvsB$Nigerian.Basal)
quantids <- rownames(designNvsB)
rownames(mm) <- quantids
colnames(mm) <- c("TCGA_black", "Nigerian")
quantdata <- as.data.frame(t(counts(ddsHTSeqMF)))
quantdata <- quantdata[quantids,]
quantdata <- t(quantdata)
d0 <- DGEList(counts=quantdata, genes=annotation)
cutoff <- 10
drop <- which(apply(cpm(d0), 1, max) < cutoff)
d <- d0[-drop,]
dim(d) # Number of genes after taking out low expressed genes
[1] 14864 64
v=voom(d,designNvsB,plot=T, normalize="quantile")
contr.matrix <- makeContrasts(TCGA_black.Basal-Nigerian.Basal, levels=colnames(designNvsB))
fit <- lmFit(v, designNvsB)
fit <- contrasts.fit(fit, contrasts=contr.matrix)
fit <- eBayes(fit)
dt <- decideTests(fit)
summary(dt)
TCGA_black.Basal - Nigerian.Basal
Down 2559
NotSig 8995
Up 3310
hist(fit$p.value, ylim=c(0,3000), main="Histogram of unadjusted p-values of differential gene expression\n between TNBC breast cancers in Nigerian and TCGA black patients\n quantile corrected")
qvals<-p.adjust(fit$p.value[,1], method='fdr')
df_limma <- data_frame(log2FoldChange = fit$coefficients[,1],
pval = fit$p.value[,1],
padj = qvals,
anno = fit$genes)
with(df_limma, plot(log2FoldChange, -log10(padj), pch=20, main="Volcano plot of differential gene expression between Basal \nbreast cancers in Nigerian and TCGA black breast cancer patients\nquantile corrected", xlim=c(-50,50), ylim=c(0,70)))
with(subset(df_limma, padj<0.05 & (2^(abs(log2FoldChange))>50)), points(log2FoldChange, -log10(padj), pch=20, col="blue"))
with(subset(df_limma, padj<0.05 & (2^(abs(log2FoldChange))>50)), textxy(log2FoldChange, -log10(padj), labs=anno$symbol, cex=.5))
df_limmaprint <- as.data.frame(df_limma)
df_limmaprint$foldChange <- NA
row.pos <- which(! is.na(df_limmaprint$log2FoldChange) &
df_limmaprint$log2FoldChange >= 0)
row.neg <- which(! is.na(df_limmaprint$log2FoldChange) &
df_limmaprint$log2FoldChange < 0)
df_limmaprint$foldChange[row.pos] <- 2^df_limmaprint$log2FoldChange[row.pos]
df_limmaprint$foldChange[row.neg] <- -2^((-1) * df_limmaprint$log2FoldChange[row.neg])
df_limmaprint <- df_limmaprint %>% arrange(foldChange) %>% dplyr::filter(padj < 0.05) %>% dplyr::filter(abs(foldChange)>1.5)
top_n(df_limmaprint, 10, foldChange)
top_n(df_limmaprint, -10, foldChange)
fit$genes$status <- ifelse(fit$F.p.value<0.05,"red","black")
limma::plotMA(fit, xlab = "Average log-expression",
ylab = "Expression log-ratio (this sample vs others)", status=fit$genes$status,
main = "MA Plot of differential gene expression between basal \nbreast cancers in Nigerian and TCGA black breast cancer patients")
write.csv(df_limmaprint, file = "TCGA_black-Nigerian-Basal.csv", row.names = FALSE)
Warning: The above code chunk cached its results, but it won’t be re-run if previous chunks it depends on are updated. If you need to use caching, it is highly recommended to also set knitr::opts_chunk$set(autodep = TRUE) at the top of the file (in a chunk that is not cached). Alternatively, you can customize the option dependson for each individual chunk that is cached. Using either autodep or dependson will remove this warning. See the knitr cache options for more details.
##DE: Nigerian/TCGA White - LumA
designNvsWHR <- design
designNvsWHR$sampleCondition <- ifelse (designNvsWHR$sampleCondition=="TCGA_white.LumA", 0, as.character(designNvsWHR$sampleCondition))
designNvsWHR$sampleCondition <- ifelse (designNvsWHR$sampleCondition=="Nigerian.LumA", 1, as.character(designNvsWHR$sampleCondition))
designNvsWHR$sampleCondition <- ifelse (designNvsWHR$sampleCondition==0 | designNvsWHR$sampleCondition==1, designNvsWHR$sampleCondition, NA)
designNvsWHR <- designNvsWHR %>% subset(is.na(sampleCondition)==FALSE)
designNvsWHR$TCGA_white.LumA <- ifelse (designNvsWHR$sampleCondition==0, 1, 0)
designNvsWHR$Nigerian.LumA <- ifelse (designNvsWHR$sampleCondition==1, 1, 0)
designNvsWHR$sampleCondition <- NULL
mm <- model.matrix(~0+designNvsWHR$TCGA_white.LumA+designNvsWHR$Nigerian.LumA)
quantids <- rownames(designNvsWHR)
rownames(mm) <- quantids
colnames(mm) <- c("TCGA_white", "Nigerian")
quantdata <- as.data.frame(t(counts(ddsHTSeqMF)))
quantdata <- quantdata[quantids,]
quantdata <- t(quantdata)
d0 <- DGEList(counts=quantdata, genes=annotation)
cutoff <- 10
drop <- which(apply(cpm(d0), 1, max) < cutoff)
d <- d0[-drop,]
dim(d) # Number of genes after taking out low expressed genes
[1] 13663 22
v=voom(d,designNvsWHR,plot=T, normalize="quantile")
contr.matrix <- makeContrasts(TCGA_white.LumA-Nigerian.LumA, levels=colnames(designNvsWHR))
fit <- lmFit(v, designNvsWHR)
fit <- contrasts.fit(fit, contrasts=contr.matrix)
fit <- eBayes(fit)
dt <- decideTests(fit)
summary(dt)
TCGA_white.LumA - Nigerian.LumA
Down 1095
NotSig 10909
Up 1659
hist(fit$p.value, ylim=c(0,3000), main="Histogram of unadjusted p-values of differential gene expression\n between LumA breast cancers in Nigerian and TCGA white patients\n quantile corrected")
qvals<-p.adjust(fit$p.value[,1], method='fdr')
df_limma <- data_frame(log2FoldChange = fit$coefficients[,1],
pval = fit$p.value[,1],
padj = qvals,
anno = fit$genes)
with(df_limma, plot(log2FoldChange, -log10(padj), pch=20, main="Volcano plot of differential gene expression between LumA \nbreast cancers in Nigerian and TCGA white breast cancer patients\nquantile corrected", xlim=c(-50,50), ylim=c(0,70)))
with(subset(df_limma, padj<0.05 & (2^(abs(log2FoldChange))>50)), points(log2FoldChange, -log10(padj), pch=20, col="blue"))
with(subset(df_limma, padj<0.05 & (2^(abs(log2FoldChange))>50)), textxy(log2FoldChange, -log10(padj), labs=anno$symbol, cex=.5))
df_limmaprint <- as.data.frame(df_limma)
df_limmaprint$foldChange <- NA
row.pos <- which(! is.na(df_limmaprint$log2FoldChange) &
df_limmaprint$log2FoldChange >= 0)
row.neg <- which(! is.na(df_limmaprint$log2FoldChange) &
df_limmaprint$log2FoldChange < 0)
df_limmaprint$foldChange[row.pos] <- 2^df_limmaprint$log2FoldChange[row.pos]
df_limmaprint$foldChange[row.neg] <- -2^((-1) * df_limmaprint$log2FoldChange[row.neg])
df_limmaprint <- df_limmaprint %>% arrange(foldChange) %>% dplyr::filter(padj < 0.05) %>% dplyr::filter(abs(foldChange)>1.5)
top_n(df_limmaprint, 10, foldChange)
top_n(df_limmaprint, -10, foldChange)
fit$genes$status <- ifelse(fit$F.p.value<0.05,"red","black")
limma::plotMA(fit, xlab = "Average log-expression",
ylab = "Expression log-ratio (this sample vs others)", status=fit$genes$status,
main = "MA Plot of differential gene expression between LumA \nbreast cancers in Nigerian and TCGA white breast cancer patients")
write.csv(df_limmaprint, file = "TCGA_white-Nigerian-LumA.csv", row.names = FALSE)
Warning: The above code chunk cached its results, but it won’t be re-run if previous chunks it depends on are updated. If you need to use caching, it is highly recommended to also set knitr::opts_chunk$set(autodep = TRUE) at the top of the file (in a chunk that is not cached). Alternatively, you can customize the option dependson for each individual chunk that is cached. Using either autodep or dependson will remove this warning. See the knitr cache options for more details.
##DE: Nigerian/TCGA Black - LumA
designNvsBHR <- design
designNvsBHR$sampleCondition <- ifelse (designNvsBHR$sampleCondition=="TCGA_black.LumA", 0, as.character(designNvsBHR$sampleCondition))
designNvsBHR$sampleCondition <- ifelse (designNvsBHR$sampleCondition=="Nigerian.LumA", 1, as.character(designNvsBHR$sampleCondition))
designNvsBHR$sampleCondition <- ifelse (designNvsBHR$sampleCondition==0 | designNvsBHR$sampleCondition==1, designNvsBHR$sampleCondition, NA)
designNvsBHR <- designNvsBHR %>% subset(is.na(sampleCondition)==FALSE)
designNvsBHR$TCGA_black.LumA <- ifelse (designNvsBHR$sampleCondition==0, 1, 0)
designNvsBHR$Nigerian.LumA <- ifelse (designNvsBHR$sampleCondition==1, 1, 0)
designNvsBHR$sampleCondition <- NULL
mm <- model.matrix(~0+designNvsBHR$TCGA_black.LumA+designNvsBHR$Nigerian.LumA)
quantids <- rownames(designNvsBHR)
rownames(mm) <- quantids
colnames(mm) <- c("TCGA_black", "Nigerian")
quantdata <- as.data.frame(t(counts(ddsHTSeqMF)))
quantdata <- quantdata[quantids,]
quantdata <- t(quantdata)
d0 <- DGEList(counts=quantdata, genes=annotation)
cutoff <- 10
drop <- which(apply(cpm(d0), 1, max) < cutoff)
d <- d0[-drop,]
dim(d) # Number of genes after taking out low expressed genes
[1] 13530 18
v=voom(d,designNvsBHR,plot=T, normalize="quantile")
contr.matrix <- makeContrasts(TCGA_black.LumA-Nigerian.LumA, levels=colnames(designNvsBHR))
fit <- lmFit(v, designNvsBHR)
fit <- contrasts.fit(fit, contrasts=contr.matrix)
fit <- eBayes(fit)
dt <- decideTests(fit)
summary(dt)
TCGA_black.LumA - Nigerian.LumA
Down 225
NotSig 13030
Up 275
hist(fit$p.value, ylim=c(0,3000), main="Histogram of unadjusted p-values of differential gene expression\n between LumA breast cancers in Nigerian and TCGA black patients\n quantile corrected")
qvals<-p.adjust(fit$p.value[,1], method='fdr')
df_limma <- data_frame(log2FoldChange = fit$coefficients[,1],
pval = fit$p.value[,1],
padj = qvals,
anno = fit$genes)
with(df_limma, plot(log2FoldChange, -log10(padj), pch=20, main="Volcano plot of differential gene expression between LumA \nbreast cancers in Nigerian and TCGA black breast cancer patients\nquantile corrected", xlim=c(-50,50), ylim=c(0,70)))
with(subset(df_limma, padj<0.05 & (2^(abs(log2FoldChange))>50)), points(log2FoldChange, -log10(padj), pch=20, col="blue"))
with(subset(df_limma, padj<0.05 & (2^(abs(log2FoldChange))>50)), textxy(log2FoldChange, -log10(padj), labs=anno$symbol, cex=.5))
df_limmaprint <- as.data.frame(df_limma)
df_limmaprint$foldChange <- NA
row.pos <- which(! is.na(df_limmaprint$log2FoldChange) &
df_limmaprint$log2FoldChange >= 0)
row.neg <- which(! is.na(df_limmaprint$log2FoldChange) &
df_limmaprint$log2FoldChange < 0)
df_limmaprint$foldChange[row.pos] <- 2^df_limmaprint$log2FoldChange[row.pos]
df_limmaprint$foldChange[row.neg] <- -2^((-1) * df_limmaprint$log2FoldChange[row.neg])
df_limmaprint <- df_limmaprint %>% arrange(foldChange) %>% dplyr::filter(padj < 0.05) %>% dplyr::filter(abs(foldChange)>1.5)
top_n(df_limmaprint, 10, foldChange)
top_n(df_limmaprint, -10, foldChange)
fit$genes$status <- ifelse(fit$F.p.value<0.05,"red","black")
limma::plotMA(fit, xlab = "Average log-expression",
ylab = "Expression log-ratio (this sample vs others)", status=fit$genes$status,
main = "MA Plot of differential gene expression between LumA \nbreast cancers in Nigerian and TCGA white breast cancer patients")
write.csv(df_limmaprint, file = "TCGA_black-Nigerian-LumA.csv", row.names = FALSE)
Warning: The above code chunk cached its results, but it won’t be re-run if previous chunks it depends on are updated. If you need to use caching, it is highly recommended to also set knitr::opts_chunk$set(autodep = TRUE) at the top of the file (in a chunk that is not cached). Alternatively, you can customize the option dependson for each individual chunk that is cached. Using either autodep or dependson will remove this warning. See the knitr cache options for more details.
##DE: Nigerian/TCGA White - LumB
designNvsWHR <- design
designNvsWHR$sampleCondition <- ifelse (designNvsWHR$sampleCondition=="TCGA_white.LumB", 0, as.character(designNvsWHR$sampleCondition))
designNvsWHR$sampleCondition <- ifelse (designNvsWHR$sampleCondition=="Nigerian.LumB", 1, as.character(designNvsWHR$sampleCondition))
designNvsWHR$sampleCondition <- ifelse (designNvsWHR$sampleCondition==0 | designNvsWHR$sampleCondition==1, designNvsWHR$sampleCondition, NA)
designNvsWHR <- designNvsWHR %>% subset(is.na(sampleCondition)==FALSE)
designNvsWHR$TCGA_white.LumB <- ifelse (designNvsWHR$sampleCondition==0, 1, 0)
designNvsWHR$Nigerian.LumB <- ifelse (designNvsWHR$sampleCondition==1, 1, 0)
designNvsWHR$sampleCondition <- NULL
mm <- model.matrix(~0+designNvsWHR$TCGA_white.LumB+designNvsWHR$Nigerian.LumB)
quantids <- rownames(designNvsWHR)
rownames(mm) <- quantids
colnames(mm) <- c("TCGA_white", "Nigerian")
quantdata <- as.data.frame(t(counts(ddsHTSeqMF)))
quantdata <- quantdata[quantids,]
quantdata <- t(quantdata)
d0 <- DGEList(counts=quantdata, genes=annotation)
cutoff <- 10
drop <- which(apply(cpm(d0), 1, max) < cutoff)
d <- d0[-drop,]
dim(d) # Number of genes after taking out low expressed genes
[1] 13082 20
v=voom(d,designNvsWHR,plot=T, normalize="quantile")
contr.matrix <- makeContrasts(TCGA_white.LumB-Nigerian.LumB, levels=colnames(designNvsWHR))
fit <- lmFit(v, designNvsWHR)
fit <- contrasts.fit(fit, contrasts=contr.matrix)
fit <- eBayes(fit)
dt <- decideTests(fit)
summary(dt)
TCGA_white.LumB - Nigerian.LumB
Down 988
NotSig 10946
Up 1148
hist(fit$p.value, ylim=c(0,3000), main="Histogram of unadjusted p-values of differential gene expression\n between LumB breast cancers in Nigerian and TCGA white patients\n quantile corrected")
qvals<-p.adjust(fit$p.value[,1], method='fdr')
df_limma <- data_frame(log2FoldChange = fit$coefficients[,1],
pval = fit$p.value[,1],
padj = qvals,
anno = fit$genes)
with(df_limma, plot(log2FoldChange, -log10(padj), pch=20, main="Volcano plot of differential gene expression between LumB \nbreast cancers in Nigerian and TCGA white breast cancer patients\nquantile corrected", xlim=c(-50,50), ylim=c(0,70)))
with(subset(df_limma, padj<0.05 & (2^(abs(log2FoldChange))>50)), points(log2FoldChange, -log10(padj), pch=20, col="blue"))
with(subset(df_limma, padj<0.05 & (2^(abs(log2FoldChange))>50)), textxy(log2FoldChange, -log10(padj), labs=anno$symbol, cex=.5))
df_limmaprint <- as.data.frame(df_limma)
df_limmaprint$foldChange <- NA
row.pos <- which(! is.na(df_limmaprint$log2FoldChange) &
df_limmaprint$log2FoldChange >= 0)
row.neg <- which(! is.na(df_limmaprint$log2FoldChange) &
df_limmaprint$log2FoldChange < 0)
df_limmaprint$foldChange[row.pos] <- 2^df_limmaprint$log2FoldChange[row.pos]
df_limmaprint$foldChange[row.neg] <- -2^((-1) * df_limmaprint$log2FoldChange[row.neg])
df_limmaprint <- df_limmaprint %>% arrange(foldChange) %>% dplyr::filter(padj < 0.05) %>% dplyr::filter(abs(foldChange)>1.5)
top_n(df_limmaprint, 10, foldChange)
top_n(df_limmaprint, -10, foldChange)
fit$genes$status <- ifelse(fit$F.p.value<0.05,"red","black")
limma::plotMA(fit, xlab = "Average log-expression",
ylab = "Expression log-ratio (this sample vs others)", status=fit$genes$status,
main = "MA Plot of differential gene expression between LumB \nbreast cancers in Nigerian and TCGA white breast cancer patients")
write.csv(df_limmaprint, file = "TCGA_white-Nigerian-LumB.csv", row.names = FALSE)
Warning: The above code chunk cached its results, but it won’t be re-run if previous chunks it depends on are updated. If you need to use caching, it is highly recommended to also set knitr::opts_chunk$set(autodep = TRUE) at the top of the file (in a chunk that is not cached). Alternatively, you can customize the option dependson for each individual chunk that is cached. Using either autodep or dependson will remove this warning. See the knitr cache options for more details.
##DE: Nigerian/TCGA Black - LumB
designNvsBHR <- design
designNvsBHR$sampleCondition <- ifelse (designNvsBHR$sampleCondition=="TCGA_black.LumB", 0, as.character(designNvsBHR$sampleCondition))
designNvsBHR$sampleCondition <- ifelse (designNvsBHR$sampleCondition=="Nigerian.LumB", 1, as.character(designNvsBHR$sampleCondition))
designNvsBHR$sampleCondition <- ifelse (designNvsBHR$sampleCondition==0 | designNvsBHR$sampleCondition==1, designNvsBHR$sampleCondition, NA)
designNvsBHR <- designNvsBHR %>% subset(is.na(sampleCondition)==FALSE)
designNvsBHR$TCGA_black.LumB <- ifelse (designNvsBHR$sampleCondition==0, 1, 0)
designNvsBHR$Nigerian.LumB <- ifelse (designNvsBHR$sampleCondition==1, 1, 0)
designNvsBHR$sampleCondition <- NULL
mm <- model.matrix(~0+designNvsBHR$TCGA_black.LumB+designNvsBHR$Nigerian.LumB)
quantids <- rownames(designNvsBHR)
rownames(mm) <- quantids
colnames(mm) <- c("TCGA_black", "Nigerian")
quantdata <- as.data.frame(t(counts(ddsHTSeqMF)))
quantdata <- quantdata[quantids,]
quantdata <- t(quantdata)
d0 <- DGEList(counts=quantdata, genes=annotation)
cutoff <- 10
drop <- which(apply(cpm(d0), 1, max) < cutoff)
d <- d0[-drop,]
dim(d) # Number of genes after taking out low expressed genes
[1] 12993 15
v=voom(d,designNvsBHR,plot=T, normalize="quantile")
contr.matrix <- makeContrasts(TCGA_black.LumB-Nigerian.LumB, levels=colnames(designNvsBHR))
fit <- lmFit(v, designNvsBHR)
fit <- contrasts.fit(fit, contrasts=contr.matrix)
fit <- eBayes(fit)
dt <- decideTests(fit)
summary(dt)
TCGA_black.LumB - Nigerian.LumB
Down 109
NotSig 12758
Up 126
hist(fit$p.value, ylim=c(0,3000), main="Histogram of unadjusted p-values of differential gene expression\n between LumB breast cancers in Nigerian and TCGA black patients\n quantile corrected")
qvals<-p.adjust(fit$p.value[,1], method='fdr')
df_limma <- data_frame(log2FoldChange = fit$coefficients[,1],
pval = fit$p.value[,1],
padj = qvals,
anno = fit$genes)
with(df_limma, plot(log2FoldChange, -log10(padj), pch=20, main="Volcano plot of differential gene expression between LumA \nbreast cancers in Nigerian and TCGA black breast cancer patients\nquantile corrected", xlim=c(-50,50), ylim=c(0,70)))
with(subset(df_limma, padj<0.05 & (2^(abs(log2FoldChange))>50)), points(log2FoldChange, -log10(padj), pch=20, col="blue"))
with(subset(df_limma, padj<0.05 & (2^(abs(log2FoldChange))>50)), textxy(log2FoldChange, -log10(padj), labs=anno$symbol, cex=.5))
df_limmaprint <- as.data.frame(df_limma)
df_limmaprint$foldChange <- NA
row.pos <- which(! is.na(df_limmaprint$log2FoldChange) &
df_limmaprint$log2FoldChange >= 0)
row.neg <- which(! is.na(df_limmaprint$log2FoldChange) &
df_limmaprint$log2FoldChange < 0)
df_limmaprint$foldChange[row.pos] <- 2^df_limmaprint$log2FoldChange[row.pos]
df_limmaprint$foldChange[row.neg] <- -2^((-1) * df_limmaprint$log2FoldChange[row.neg])
df_limmaprint <- df_limmaprint %>% arrange(foldChange) %>% dplyr::filter(padj < 0.05) %>% dplyr::filter(abs(foldChange)>1.5)
top_n(df_limmaprint, 10, foldChange)
top_n(df_limmaprint, -10, foldChange)
fit$genes$status <- ifelse(fit$F.p.value<0.05,"red","black")
limma::plotMA(fit, xlab = "Average log-expression",
ylab = "Expression log-ratio (this sample vs others)", status=fit$genes$status,
main = "MA Plot of differential gene expression between LumB \nbreast cancers in Nigerian and TCGA black breast cancer patients")
write.csv(df_limmaprint, file = "TCGA_black-Nigerian-LumB.csv", row.names = FALSE)
Warning: The above code chunk cached its results, but it won’t be re-run if previous chunks it depends on are updated. If you need to use caching, it is highly recommended to also set knitr::opts_chunk$set(autodep = TRUE) at the top of the file (in a chunk that is not cached). Alternatively, you can customize the option dependson for each individual chunk that is cached. Using either autodep or dependson will remove this warning. See the knitr cache options for more details.
##DE: Nigerian/TCGA White - HER2 (no TCGA Black HER2+ patients)
designNvsWHER2 <- design
designNvsWHER2$sampleCondition <- ifelse (designNvsWHER2$sampleCondition=="TCGA_white.Her2", 0, as.character(designNvsWHER2$sampleCondition))
designNvsWHER2$sampleCondition <- ifelse (designNvsWHER2$sampleCondition=="Nigerian.Her2", 1, as.character(designNvsWHER2$sampleCondition))
designNvsWHER2$sampleCondition <- ifelse (designNvsWHER2$sampleCondition==0 | designNvsWHER2$sampleCondition==1, designNvsWHER2$sampleCondition, NA)
designNvsWHER2 <- designNvsWHER2 %>% subset(is.na(sampleCondition)==FALSE)
designNvsWHER2$TCGA_white.Her2 <- ifelse (designNvsWHER2$sampleCondition==0, 1, 0)
designNvsWHER2$Nigerian.Her2 <- ifelse (designNvsWHER2$sampleCondition==1, 1, 0)
designNvsWHER2$sampleCondition <- NULL
mm <- model.matrix(~0+designNvsWHER2$TCGA_white.Her2+designNvsWHER2$Nigerian.Her2)
quantids <- rownames(designNvsWHER2)
rownames(mm) <- quantids
colnames(mm) <- c("TCGA_white", "Nigerian")
quantdata <- as.data.frame(t(counts(ddsHTSeqMF)))
quantdata <- quantdata[quantids,]
quantdata <- t(quantdata)
d0 <- DGEList(counts=quantdata, genes=annotation)
cutoff <- 10
drop <- which(apply(cpm(d0), 1, max) < cutoff)
d <- d0[-drop,]
dim(d) # Number of genes after taking out low expressed genes
[1] 13869 32
v=voom(d,designNvsWHER2,plot=T, normalize="quantile")
contr.matrix <- makeContrasts(TCGA_white.Her2-Nigerian.Her2, levels=colnames(designNvsWHER2))
fit <- lmFit(v, designNvsWHER2)
fit <- contrasts.fit(fit, contrasts=contr.matrix)
fit <- eBayes(fit)
dt <- decideTests(fit)
summary(dt)
TCGA_white.Her2 - Nigerian.Her2
Down 332
NotSig 12867
Up 670
hist(fit$p.value, ylim=c(0,3000), main="Histogram of unadjusted p-values of differential gene expression\n between Her2+ breast cancers in Nigerian and TCGA white patients\n quantile corrected")
qvals<-p.adjust(fit$p.value[,1], method='fdr')
df_limma <- data_frame(log2FoldChange = fit$coefficients[,1],
pval = fit$p.value[,1],
padj = qvals,
anno = fit$genes)
with(df_limma, plot(log2FoldChange, -log10(padj), pch=20, main="Volcano plot of differential gene expression between Her2+ \nbreast cancers in Nigerian and TCGA white breast cancer patients\nquantile corrected", xlim=c(-50,50), ylim=c(0,70)))
with(subset(df_limma, padj<0.05 & (2^(abs(log2FoldChange))>50)), points(log2FoldChange, -log10(padj), pch=20, col="blue"))
with(subset(df_limma, padj<0.05 & (2^(abs(log2FoldChange))>50)), textxy(log2FoldChange, -log10(padj), labs=anno$symbol, cex=.5))
df_limmaprint <- as.data.frame(df_limma)
df_limmaprint$foldChange <- NA
row.pos <- which(! is.na(df_limmaprint$log2FoldChange) &
df_limmaprint$log2FoldChange >= 0)
row.neg <- which(! is.na(df_limmaprint$log2FoldChange) &
df_limmaprint$log2FoldChange < 0)
df_limmaprint$foldChange[row.pos] <- 2^df_limmaprint$log2FoldChange[row.pos]
df_limmaprint$foldChange[row.neg] <- -2^((-1) * df_limmaprint$log2FoldChange[row.neg])
df_limmaprint <- df_limmaprint %>% arrange(foldChange) %>% dplyr::filter(padj < 0.05) %>% dplyr::filter(abs(foldChange)>1.5)
top_n(df_limmaprint, 10, foldChange)
top_n(df_limmaprint, -10, foldChange)
fit$genes$status <- ifelse(fit$F.p.value<0.05,"red","black")
limma::plotMA(fit, xlab = "Average log-expression",
ylab = "Expression log-ratio (this sample vs others)", status=fit$genes$status,
main = "MA Plot of differential gene expression between Her2 \nbreast cancers in Nigerian and TCGA white breast cancer patients")
write.csv(df_limmaprint, file = "TCGAwhite-Nigerian-Her2.csv", row.names = FALSE)
Warning: The above code chunk cached its results, but it won’t be re-run if previous chunks it depends on are updated. If you need to use caching, it is highly recommended to also set knitr::opts_chunk$set(autodep = TRUE) at the top of the file (in a chunk that is not cached). Alternatively, you can customize the option dependson for each individual chunk that is cached. Using either autodep or dependson will remove this warning. See the knitr cache options for more details.
mm <- model.matrix(~0+designNvsW$TCGA_white.Basal+designNvsW$Nigerian.Basal)
quantids <- rownames(designNvsW)
rownames(mm) <- quantids
colnames(mm) <- c("TCGA_white", "Nigerian")
quantdata <- as.data.frame(t(counts(ddsHTSeqMF)))
quantdata <- quantdata[quantids,]
quantdata <- t(quantdata)
d0 <- DGEList(counts=quantdata, genes=annotation)
cutoff <- 10
drop <- which(apply(cpm(d0), 1, max) < cutoff)
d <- d0[-drop,]
dim(d) # Number of genes after taking out low expressed genes
[1] 14785 58
v=voom(d,designNvsW,plot=T, normalize="quantile")
contr.matrix <- makeContrasts(TCGA_white.Basal-Nigerian.Basal, levels=colnames(designNvsW))
fit <- lmFit(v, designNvsW)
fit <- contrasts.fit(fit, contrasts=contr.matrix)
fit <- eBayes(fit)
dt <- decideTests(fit)
summary(dt)
TCGA_white.Basal - Nigerian.Basal
Down 2346
NotSig 9093
Up 3346
df_limma <- data_frame(log2FoldChange = fit$coefficients[,1],
pval = fit$p.value[,1],
padj = p.adjust(fit$p.value[,1], method='fdr'),
anno = fit$genes)
pathway.Nigerian.TCGAwhite.Basal <- as.data.frame(df_limma)
pathway.Nigerian.TCGAwhite.Basal$foldChange <- NA
row.pos <- which(! is.na(pathway.Nigerian.TCGAwhite.Basal$log2FoldChange) &
pathway.Nigerian.TCGAwhite.Basal$log2FoldChange >= 0)
row.neg <- which(! is.na(pathway.Nigerian.TCGAwhite.Basal$log2FoldChange) &
pathway.Nigerian.TCGAwhite.Basal$log2FoldChange < 0)
pathway.Nigerian.TCGAwhite.Basal$foldChange[row.pos] <- 2^pathway.Nigerian.TCGAwhite.Basal$log2FoldChange[row.pos]
pathway.Nigerian.TCGAwhite.Basal$foldChange[row.neg] <- -2^((-1) * pathway.Nigerian.TCGAwhite.Basal$log2FoldChange[row.neg])
pathway.Nigerian.TCGAwhite.Basal$log2FoldChange <- NULL
pathway.Nigerian.TCGAwhite.Basal$ENSEMBL <- pathway.Nigerian.TCGAwhite.Basal$anno$GeneID
pathway.Nigerian.TCGAwhite.Basal$SYMBOL <- pathway.Nigerian.TCGAwhite.Basal$anno$symbol
pathway.Nigerian.TCGAwhite.Basal$anno$GeneID <- NULL
pathway.Nigerian.TCGAwhite.Basal$anno$symbol <- NULL
pathway.Nigerian.TCGAwhite.Basal.flt <- pathway.Nigerian.TCGAwhite.Basal %>% arrange(foldChange) %>% dplyr::filter(padj < 0.05) %>% dplyr::filter(abs(foldChange)>1.5)
genes.all <- pathway.Nigerian.TCGAwhite.Basal
genes.sig <- pathway.Nigerian.TCGAwhite.Basal.flt
genes.all$ENSEMBL <- gsub('[.]\\d+', '', genes.all$ENSEMBL, perl = TRUE)
genes.sig$ENSEMBL <- gsub('[.]\\d+', '', genes.sig$ENSEMBL, perl = TRUE)
genes.all.anno <- bitr(geneID = genes.all$ENSEMBL,
fromType = 'GENEID',
toType = c('ENTREZID', 'SYMBOL'),
OrgDb = 'EnsDb.Hsapiens.v75',
drop = TRUE)
genes.all.anno <- genes.all.anno[which(!duplicated(genes.all.anno$ENTREZID)), ]
row.names(genes.all.anno) <- genes.all.anno$ENTREZID
genes.all.anno$ENSEMBL <- genes.all.anno$GENEID
genes.all.anno$GENEID <- NULL
genes.all.anno <- merge(genes.all.anno, genes.all, by = 'ENSEMBL')
row.names(genes.all.anno) <- genes.all.anno$ENTREZID
genes.sig.anno <- genes.all.anno[genes.all.anno$ENSEMBL %in%
genes.sig$ENSEMBL,]
gene.list <- genes.all.anno$foldChange
names(gene.list) <- genes.all.anno$ENTREZID
gene.list <- sort(gene.list, decreasing = TRUE)
ego <- enrichGO(gene = genes.sig.anno$ENTREZID,
universe = as.character(genes.all.anno$ENTREZID),
OrgDb = 'org.Hs.eg.db',
ont = "BP",
pAdjustMethod = "fdr",
pvalueCutoff = 0.05,
readable = TRUE)
as.data.frame(ego)
save(ego, file="GO-Nigerian-TCGAwhite-Basal.significantgenes.fdr0.05.fc1.5.enrichGO.RData")
write.csv(ego, file="GO-Nigerian-TCGAwhite-Basal.significantgenes.fdr0.05.fc1.5.enrichGO.csv")
options(jupyter.plot_mimetypes = "image/svg+xml")
options(repr.plot.width = 10, repr.plot.height = 5)
egokegg <- ego
for(i in 1:5) {
egokegg <- dropGO(egokegg, level = i)
}
p1 <- barplot(egokegg)
p2 <- dotplot(egokegg)
kk <- enrichKEGG(gene = genes.sig.anno$ENTREZID,
universe = as.character(genes.all.anno$ENTREZID),
organism = "hsa",
pAdjustMethod = "fdr",
pvalueCutoff = 0.05)
plot(p1)
plot(p2)
save(kk, file="GO-Nigerian-TCGAwhite-Basal.significantgenes.fdr0.05.fc1.5.enrichKEGG.RData")
write.csv(kk@result, file="GO-Nigerian-TCGAwhite-Basal.significantgenes.fdr0.05.fc1.5.enrichKEGG.csv")
Warning: The above code chunk cached its results, but it won’t be re-run if previous chunks it depends on are updated. If you need to use caching, it is highly recommended to also set knitr::opts_chunk$set(autodep = TRUE) at the top of the file (in a chunk that is not cached). Alternatively, you can customize the option dependson for each individual chunk that is cached. Using either autodep or dependson will remove this warning. See the knitr cache options for more details.
mm <- model.matrix(~0+designNvsWHER2$TCGA_white.Her2+designNvsWHER2$Nigerian.Her2)
quantids <- rownames(designNvsWHER2)
rownames(mm) <- quantids
colnames(mm) <- c("TCGA_white", "Nigerian")
quantdata <- as.data.frame(t(counts(ddsHTSeqMF)))
quantdata <- quantdata[quantids,]
quantdata <- t(quantdata)
d0 <- DGEList(counts=quantdata, genes=annotation)
cutoff <- 10
drop <- which(apply(cpm(d0), 1, max) < cutoff)
d <- d0[-drop,]
dim(d) # Number of genes after taking out low expressed genes
[1] 13869 32
v=voom(d,designNvsWHER2,plot=T, normalize="quantile")
contr.matrix <- makeContrasts(TCGA_white.Her2-Nigerian.Her2, levels=colnames(designNvsWHER2))
fit <- lmFit(v, designNvsWHER2)
fit <- contrasts.fit(fit, contrasts=contr.matrix)
fit <- eBayes(fit)
dt <- decideTests(fit)
summary(dt)
TCGA_white.Her2 - Nigerian.Her2
Down 332
NotSig 12867
Up 670
qvals<-p.adjust(fit$p.value[,1], method='fdr')
df_limma <- data_frame(log2FoldChange = fit$coefficients[,1],
pval = fit$p.value[,1],
padj = qvals,
anno = fit$genes)
pathway.Nigerian.TCGAwhite.Her2 <- as.data.frame(df_limma)
pathway.Nigerian.TCGAwhite.Her2$foldChange <- NA
row.pos <- which(! is.na(pathway.Nigerian.TCGAwhite.Her2$log2FoldChange) &
pathway.Nigerian.TCGAwhite.Her2$log2FoldChange >= 0)
row.neg <- which(! is.na(pathway.Nigerian.TCGAwhite.Her2$log2FoldChange) &
pathway.Nigerian.TCGAwhite.Her2$log2FoldChange < 0)
pathway.Nigerian.TCGAwhite.Her2$foldChange[row.pos] <- 2^pathway.Nigerian.TCGAwhite.Her2$log2FoldChange[row.pos]
pathway.Nigerian.TCGAwhite.Her2$foldChange[row.neg] <- -2^((-1) * pathway.Nigerian.TCGAwhite.Her2$log2FoldChange[row.neg])
pathway.Nigerian.TCGAwhite.Her2$log2FoldChange <- NULL
pathway.Nigerian.TCGAwhite.Her2$ENSEMBL <- pathway.Nigerian.TCGAwhite.Her2$anno$GeneID
pathway.Nigerian.TCGAwhite.Her2$SYMBOL <- pathway.Nigerian.TCGAwhite.Her2$anno$symbol
pathway.Nigerian.TCGAwhite.Her2$anno$GeneID <- NULL
pathway.Nigerian.TCGAwhite.Her2$anno$symbol <- NULL
pathway.Nigerian.TCGAwhite.Her2.flt <- pathway.Nigerian.TCGAwhite.Her2 %>% arrange(foldChange) %>% dplyr::filter(padj < 0.05) %>% dplyr::filter(abs(foldChange)>1.5)
genes.all <- pathway.Nigerian.TCGAwhite.Her2
genes.sig <- pathway.Nigerian.TCGAwhite.Her2.flt
genes.all$ENSEMBL <- gsub('[.]\\d+', '', genes.all$ENSEMBL, perl = TRUE)
genes.sig$ENSEMBL <- gsub('[.]\\d+', '', genes.sig$ENSEMBL, perl = TRUE)
genes.all.anno <- bitr(geneID = genes.all$ENSEMBL,
fromType = 'GENEID',
toType = c('ENTREZID', 'SYMBOL'),
OrgDb = 'EnsDb.Hsapiens.v75',
drop = TRUE)
genes.all.anno <- genes.all.anno[which(!duplicated(genes.all.anno$ENTREZID)), ]
row.names(genes.all.anno) <- genes.all.anno$ENTREZID
genes.all.anno$ENSEMBL <- genes.all.anno$GENEID
genes.all.anno$GENEID <- NULL
genes.all.anno <- merge(genes.all.anno, genes.all, by = 'ENSEMBL')
row.names(genes.all.anno) <- genes.all.anno$ENTREZID
genes.sig.anno <- genes.all.anno[genes.all.anno$ENSEMBL %in%
genes.sig$ENSEMBL,]
gene.list <- genes.all.anno$foldChange
names(gene.list) <- genes.all.anno$ENTREZID
gene.list <- sort(gene.list, decreasing = TRUE)
ego <- enrichGO(gene = genes.sig.anno$ENTREZID,
universe = as.character(genes.all.anno$ENTREZID),
OrgDb = 'org.Hs.eg.db',
ont = "BP",
pAdjustMethod = "fdr",
pvalueCutoff = 0.05,
readable = TRUE)
as.data.frame(ego)
save(ego, file="GO-Nigerian-TCGAwhite-Her2.significantgenes.fdr0.05.fc1.5.enrichGO.RData")
write.csv(ego, file="GO-Nigerian-TCGAwhite-Her2.significantgenes.fdr0.05.fc1.5.enrichGO.csv")
options(jupyter.plot_mimetypes = "image/svg+xml")
options(repr.plot.width = 10, repr.plot.height = 5)
egokegg <- ego
for(i in 1:5) {
egokegg <- dropGO(egokegg, level = i)
}
p1 <- barplot(egokegg)
p2 <- dotplot(egokegg)
kk <- enrichKEGG(gene = genes.sig.anno$ENTREZID,
universe = as.character(genes.all.anno$ENTREZID),
organism = "hsa",
pAdjustMethod = "fdr",
pvalueCutoff = 0.05)
plot(p1)
plot(p2)
save(kk, file="GO-Nigerian-TCGAwhite-Her2.significantgenes.fdr0.05.fc1.5.enrichKEGG.RData")
write.csv(kk@result, file="GO-Nigerian-TCGAwhite-Her2.significantgenes.fdr0.05.fc1.5.enrichKEGG.csv")
testgenename="ENSG00000118181.6"
dds <- estimateSizeFactors(ddsHTSeqMF)
plotCounts(dds, gene = testgenename, intgroup=c("condition1"), main="Distribution of RPS25 expression across groups (before DE analysis)")
Warning: The above code chunk cached its results, but it won’t be re-run if previous chunks it depends on are updated. If you need to use caching, it is highly recommended to also set knitr::opts_chunk$set(autodep = TRUE) at the top of the file (in a chunk that is not cached). Alternatively, you can customize the option dependson for each individual chunk that is cached. Using either autodep or dependson will remove this warning. See the knitr cache options for more details.
sessionInfo()
R version 3.6.0 (2019-04-26)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Sierra 10.12.6
Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] parallel stats4 grid stats graphics grDevices utils
[8] datasets methods base
other attached packages:
[1] AnnotationHub_2.16.1 BiocFileCache_1.8.0
[3] dbplyr_1.4.2 Glimma_1.12.0
[5] RColorBrewer_1.1-2 preprocessCore_1.46.0
[7] ashr_2.2-32 ggfortify_0.4.7
[9] calibrate_1.7.2 MASS_7.3-51.4
[11] sva_3.32.1 mgcv_1.8-28
[13] nlme_3.1-140 EnsDb.Hsapiens.v75_2.99.0
[15] ensembldb_2.8.0 AnnotationFilter_1.8.0
[17] GenomicFeatures_1.36.1 hexbin_1.27.3
[19] stringi_1.4.3 dplyr_0.8.1
[21] affy_1.62.0 checkmate_1.9.3
[23] pathview_1.24.0 org.Hs.eg.db_3.8.2
[25] AnnotationDbi_1.46.0 clusterProfiler_3.12.0
[27] pheatmap_1.0.12 genefilter_1.66.0
[29] vsn_3.52.0 RUVSeq_1.18.0
[31] EDASeq_2.18.0 ShortRead_1.42.0
[33] GenomicAlignments_1.20.0 Rsamtools_2.0.0
[35] Biostrings_2.52.0 XVector_0.24.0
[37] DESeq2_1.24.0 SummarizedExperiment_1.14.0
[39] DelayedArray_0.10.0 BiocParallel_1.18.0
[41] matrixStats_0.54.0 Biobase_2.44.0
[43] GenomicRanges_1.36.0 GenomeInfoDb_1.20.0
[45] IRanges_2.18.1 S4Vectors_0.22.0
[47] BiocGenerics_0.30.0 edgeR_3.26.4
[49] limma_3.40.2 ggbiplot_0.55
[51] scales_1.0.0 plyr_1.8.4
[53] ggplot2_3.1.1 gplots_3.0.1.1
loaded via a namespace (and not attached):
[1] R.utils_2.8.0 tidyselect_0.2.5
[3] RSQLite_2.1.1 htmlwidgets_1.3
[5] DESeq_1.36.0 munsell_0.5.0
[7] codetools_0.2-16 withr_2.1.2
[9] colorspace_1.4-1 GOSemSim_2.10.0
[11] knitr_1.23 rstudioapi_0.10
[13] pscl_1.5.2 DOSE_3.10.1
[15] labeling_0.3 git2r_0.25.2
[17] KEGGgraph_1.44.0 urltools_1.7.3
[19] GenomeInfoDbData_1.2.1 mixsqp_0.1-97
[21] hwriter_1.3.2 polyclip_1.10-0
[23] bit64_0.9-7 farver_1.1.0
[25] rprojroot_1.3-2 xfun_0.7
[27] doParallel_1.0.14 R6_2.4.0
[29] locfit_1.5-9.1 bitops_1.0-6
[31] fgsea_1.10.0 gridGraphics_0.4-1
[33] assertthat_0.2.1 promises_1.0.1
[35] ggraph_1.0.2 nnet_7.3-12
[37] enrichplot_1.4.0 gtable_0.3.0
[39] workflowr_1.4.0 rlang_0.3.4
[41] splines_3.6.0 rtracklayer_1.44.0
[43] lazyeval_0.2.2 acepack_1.4.1
[45] europepmc_0.3 BiocManager_1.30.4
[47] yaml_2.2.0 reshape2_1.4.3
[49] backports_1.1.4 httpuv_1.5.2
[51] qvalue_2.16.0 Hmisc_4.2-0
[53] tools_3.6.0 ggplotify_0.0.3
[55] affyio_1.54.0 ggridges_0.5.1
[57] Rcpp_1.0.1 base64enc_0.1-3
[59] progress_1.2.2 zlibbioc_1.30.0
[61] purrr_0.3.2 RCurl_1.95-4.12
[63] prettyunits_1.0.2 rpart_4.1-15
[65] viridis_0.5.1 cowplot_0.9.4
[67] ggrepel_0.8.1 cluster_2.0.9
[69] fs_1.3.1 magrittr_1.5
[71] data.table_1.12.2 DO.db_2.9
[73] triebeard_0.3.0 truncnorm_1.0-8
[75] SQUAREM_2017.10-1 ProtGenerics_1.16.0
[77] aroma.light_3.14.0 mime_0.7
[79] hms_0.4.2 evaluate_0.14
[81] xtable_1.8-4 XML_3.98-1.20
[83] gridExtra_2.3 compiler_3.6.0
[85] biomaRt_2.40.0 tibble_2.1.3
[87] KernSmooth_2.23-15 crayon_1.3.4
[89] R.oo_1.22.0 htmltools_0.3.6
[91] later_0.8.0 Formula_1.2-3
[93] tidyr_0.8.3 geneplotter_1.62.0
[95] DBI_1.0.0 tweenr_1.0.1
[97] rappdirs_0.3.1 Matrix_1.2-17
[99] R.methodsS3_1.7.1 gdata_2.18.0
[101] igraph_1.2.4.1 pkgconfig_2.0.2
[103] rvcheck_0.1.3 foreign_0.8-71
[105] foreach_1.4.4 xml2_1.2.0
[107] annotate_1.62.0 stringr_1.4.0
[109] digest_0.6.19 graph_1.62.0
[111] rmarkdown_1.13 fastmatch_1.1-0
[113] htmlTable_1.13.1 curl_3.3
[115] shiny_1.3.2 gtools_3.8.1
[117] jsonlite_1.6 viridisLite_0.3.0
[119] pillar_1.4.1 lattice_0.20-38
[121] KEGGREST_1.24.0 httr_1.4.0
[123] survival_2.44-1.1 GO.db_3.8.2
[125] interactiveDisplayBase_1.22.0 glue_1.3.1
[127] UpSetR_1.4.0 iterators_1.0.10
[129] png_0.1-7 bit_1.1-14
[131] Rgraphviz_2.28.0 ggforce_0.2.2
[133] blob_1.1.1 latticeExtra_0.6-28
[135] caTools_1.17.1.2 memoise_1.1.0